﻿@using thousandClear.Areas.Admin.Models;
@model List<GoodViewModel>
@{
    ViewBag.Title = "商品管理";
    Layout = "~/Areas/Admin/Views/Shared/_Admin.cshtml";
}


@*<div id="app">

    <iframe style="width:1000px; height:800px;" src="http://www.qianjing-china.com/QianJing/Admin/good?page=1&count=10"></iframe>

</div>*@


<div id="app">
    <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">后台管理</strong> / <small>商品管理</small></div>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <a href="~/Admin/ShopItem/Add" class="am-btn am-btn-primary"><span class="am-icon-plus"></span> 新增商品</a>
                    @*<button type="button" class="am-btn am-btn-default"><span class="am-icon-plus"></span>新增商品分类</button>*@
                </div>
            </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">
            @*<div class="am-form-group">
                    <select>
                        <option value="option1">全部</option>
                        <option value="option1">素人</option>
                        <option value="option2">初级</option>
                        <option value="option3">中级</option>
                        <option value="option3">高级</option>
                    </select>
                </div>*@
        </div>
        <div class="am-u-sm-12 am-u-md-3">
            @*<div class="am-input-group am-input-group-sm">
                    <input type="text" class="am-form-field" placeholder="请输入商品名称">
                    <span class="am-input-group-btn">
                        <button class="am-btn am-btn-default" type="button">搜索</button>
                    </span>
                </div>*@
        </div>
        <div class="am-g">
            <div class="am-u-sm-12">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>商品名称</th>
                            <th>价格</th>
                            @*<th>市场价</th>*@
                            @*<th>重量(公斤)</th>*@
                            <th>积分</th>
                            <th>排序</th>
                            @*<th>库存</th>*@
                            <th>是否上架</th>
                            <th>测试专用</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (GoodViewModel item in Model)
                        {
                            <tr>
                                <td>@item.Id</td>
                                <td>@item.Name</td>
                                <td>@item.SalePrice</td>
                                @*<td>@item.MarketPrice</td>*@
                                @*<td>@item.Weight</td>*@
                                <td>@item.Credit</td>
                                <td>@item.SeqNum</td>
                                @*<td>@item.Inventory</td>*@
                                <td>
                                    @if (item.Putaway == 0)
                                    {
                                        <span>否</span>
                                    }
                                    else
                                    {
                                        <span>是</span>
                                    }
                                </td>
                                <td>
                                    @if (item.Mode == 0)
                                    {
                                        <span>否</span>
                                    }
                                    else
                                    {
                                        <span>是</span>
                                    }
                                </td>
                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            @*<a class="am-btn am-btn-danger am-btn-xs am-hide-sm-only"><span class="am-icon-copy"></span> 查看</a>*@
                                            <a href="~/admin/ShopItem/Edit/@item.Id" class="am-btn am-btn-primary am-btn-xs am-hide-sm-only"><span class="am-icon-edit"></span> 修改</a>
                                            <a onclick="removeGood(@item.Id)" class="am-btn am-btn-primary am-btn-xs am-hide-sm-only"><span class="am-icon-edit"></span> 删除</a>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                <div class="am-cf">
                    &nbsp;&nbsp;共 @ViewBag.TotalCount 条记录, 每页 @ViewBag.PageCount 条记录
                    <div class="am-fr">
                        <ul class="am-pagination">
                            <li><a href="@ViewBag.PrevPageUrl">&laquo; Prev</a></li>
                            <li><span>@ViewBag.CurrentPage/@ViewBag.TotalPage</span></li>
                            <li><a href="@ViewBag.NextPageUrl">Next &raquo;</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section Scripts{
    <script>

        $('.admin-sidebar-shopItem').addClass('current');


        function removeGood(obj){
            var c = confirm('确认要删除吗?');
            if (c) {
                var data1 = '{"goodid":"'+obj.toString()+'"}';
                $.ajax({
                    type: "POST",
                    url: "../admin/ShopItem/RemoveGood",
                    contentType: "application/json",
                    data: data1,
                    success: function (responseData) {
                        window.location.href="../admin/ShopItem";
                        alert("删除成功");
                       
                    }
                });

            }
            else {
                return;
            }
        }


        function go() {
            var page ="../../../Admin/ShopItem?count=10&pg="+ $("#page").val().toString();
            //alert(page);

            window.location.href =page;

        }
        $('#btnSearch').click(function () {
            window.location.href = "../../../Admin/ShopItem?count=10&pg=1&n=" + $('#txtName').val();
        })
    </script>
}
